home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: Call order of constructors
- Date: Mon, 19 Feb 1996 18:07:20 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4gae7m$7ar@news.halcyon.com>
- References: <4ftv2n$kts@ccnet3.ccnet.com>
- NNTP-Posting-Host: blv-pm12-ip19.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- O.K., TRANSPORT's ctor accepts a string identifying the transport and
- the ctor does of series of strcmpi() calls to match this name. If a
- match is found, the "magic stuff" is initialized appropriately,
- otherwise the object initializes in a null-state.
-
- Rather than SESSION testing it's transport for null-state, you'd
- rather the TRANSPORT ctor threw an exception. Look up try, catch, and
- throw. You may also have to set a compiler switch to generate
- exception unwinding code.
-
- What is the compiler griping about in your TRANSPORT ctor?
-
- BTW, you may want to create a TRANSPORT_FACTORY class
- that has a Make method returning a TRANSPORT *. You can readily add
- new transports without having to recompile every client of a
- transport.
-
- --Norm
-
- jantypas@ccnet.com (John Antypas) wrote:
-
- >Hello C++ wizards...
-
- >I'm trying to create a library access some private netowrk resources.
- >I thought I'd try something like this:
-
- >class TRANSPORT {
- > ... magic stuff...
- >public:
- > TRANSPORT(char *name) // Called to activate and bind transport(name)
- > ~TRANSPORT() // Called when we're done with transport(name)
-
- >}
-
- >class SESSION(
- > TRANSPORT transport&;
- > ....
- > SESSION(char *transport_name,
- > char *transport_address);
- > ~SESSION();
- > ....
- >}
-
- >I was hoping that main code such as :
-
- > SESSION my_session("iee488", "unit-4B");
-
- >would create a session on the IEEE488 controller, to unit Unit-4B, specifically, - open a trasnport to the IEEE-488 system by calling the IEEE488
- > constructor
- > - open a session by calling the session constructor and have it
- > finish the job.
-
- >The destructor sequence runs in the exact reverse.
-
- >First off, the compiler complains about the TRANSPORT constructors, second,
- >I find myself asking what to do if a constructor or destructor fails?
- >How do I catch the error condition to notify outer levels of the program?
-
- >Help as always is appreciated.
-
- >John Antypas jantypas@soft21.s21.com
-
- >--
- >John Antypas@21st Century Softwware (jantypas@soft21.s21.com)
-
- >"God is too busy to create chaos and disorder in this world, he can't be
- > everywhere at once all of the time, That's why he made two year olds"
-
-
-